<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="员工" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script language="javascript">
	function doNew(){
		var url="/base/StafferNew.ihtm?department_id=${departmentId}";
		parent.ShowIframe("员工",url,900,475,"refreshStaWin()",900,640);//refreshStaWin是父窗口的
	}
	function refreshWin(){//父窗口的refreshStaWin调用
		window.location.reload(true);
	}
	function doEdit(id){
		var url="/base/StafferEdit.ihtm?id="+id;
		parent.ShowIframe("员工",url,900,475,"refreshStaWin()",900,640);//refreshStaWin是父窗口的
	}
	function doDelete(id){
		parent.ShowConfirm('确认框','删除员工将同时删除该员工的所有账号，确定删除吗？',340,80,"doDelSta("+id+")");//doDelSta是父窗口的
	}
	function doDelAct(id){//是父窗口的doDelSta调用
		var fromUrl=getFromUrl();
		window.location="/base/StafferDelete.ihtm?id="+id+"&from_url="+fromUrl;
	}
	function getFromUrl(){
		var departmentId="${departmentId}";
		var searchKey=encodeURIComponent("${searchKey}");
		var searchAll="${searchAll}";
		var fromUrl="/base/StafferList.ihtm?department_id="+departmentId+"&search_key="+searchKey+"&search_all="+searchAll;
		return encodeURIComponent(fromUrl);
	}
	function doSearch(){
		var departmentId="${departmentId}";
		var searchKey=encodeURIComponent(document.getElementById("search_key").value.trim());
		var searchAll="";
		if(document.getElementById("search_all").checked){
			searchAll="1";
		}
		window.location="/base/StafferList.ihtm?department_id="+departmentId+"&search_key="+searchKey+"&search_all="+searchAll;
	}
	function doInit(){
		Window_Onload();
		document.getElementById("search_key").focus();
	}
	function checkSearchKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doDownload(){
		var departmentId="${departmentId}";
		var searchKey=encodeURIComponent("<c:out value="${searchKey}" />");
		var searchAll="${searchAll}";
		window.location="/base/StafferList.ihtm?content_type=EXCEL&department_id="+departmentId+"&search_key="+searchKey+"&search_all="+searchAll;
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		if(ob_arr.length>=it.getAttribute("index")){
			str=ob_arr[it.getAttribute("index")-1].value;
		}
		if(str==""){
			return;
		}
		doEdit(str);
	}
	function doPause(id){
		var fromUrl=getFromUrl();
		window.location="/base/StafferPause.ihtm?id="+id+"&from_url="+fromUrl;
	}
</script>
</head>
<body oncontextmenu="return false" onload="doInit();" scroll="no" style="background: #EAFAFF;">
		<div id="scrollDiv" style="OVERFLOW:auto;height:508px">
		  <div class="main search-business">
			   <div class="cue-info">
					<h4>
						<c:if test="${searchAll=='1'}">所有部门 - 员工</c:if>
						<c:if test="${searchAll!='1'}">${department.departmentName} -  员工</c:if>
					</h4>				   	
			  </div>
			  <div class="content">		
				  <div align="right">
					<input type="text" class="TextBox" id="search_key" name="search_key" onKeyUp="checkSearchKey();"  value="${searchKey}" title="以员工姓名、姓名拼音字头进行模糊查询">
					<input type="checkbox" id="search_all" name="search_all" <c:if test="${searchAll=='1'}">checked</c:if>>在所有部门中查找
					<input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();" title="以员工姓名、姓名拼音字头进行模糊查询">		
					<input type="button" class="buttom search-add " value=" 新 增" onClick="doNew();">
					<input type="button" class="buttom search-out" value=" 导 出" onClick="doDownload();" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
				  </div>
			  </div>			  
			  <%@include file="../inc/AlertMsg.jsp"%>
			  <div class="table-list" style="width:97%; padding:15px 0 15px 10px; float:left;">
			  	<span>在职人数：${enabledCount}</span>&nbsp;&nbsp;
				<span>离职人数：${unenabledCount}</span>&nbsp;&nbsp;
						<table width="100%">
							<tr>
								<th width="15%">部门</th>
								<th width="15%">姓名</th>
								<th width="13%">职位</th>
								<th width="15%">上级</th>
								<th width="16%">入职日期</th>
								<th width="10%">状态</th>
								<th width="16%">操作</th>
							</tr>
							<c:forEach var="item" items="${stafferList}" varStatus="i">
							<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
							<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
							<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' onmouseout='javascript:mouseout(this)' ondblclick='javascript:DoubleClick(this)' onmouseover='javascript:mouseover(this)' onClick='javascript:ClickCheck(this)'>
								<td>
									<input type="radio" onClick="javascript:ClickCheck(this);" name='query_checkbox' value="${item.staffer.id}" style="display:none">
									${item.depName}
								</td>
								<td>${item.staffer.stafferName}</td>
								<td>${item.staffer.possie}</td>
								<td>${item.superiorName}</td>
								<td><c:if test="${item.staffer.inDate!=null}"><fmt:formatDate value="${item.staffer.inDate}" pattern="yyyy-MM-dd"/></c:if></td>
								<td>
									<c:if test="${item.staffer.enabled=='Y'}">在职</c:if>
									<c:if test="${item.staffer.enabled!='Y'}"><font color="#ff0000">离职</font></c:if>
								</td>
								<td>
									<a href="javascript:doEdit('${item.staffer.id}');">编辑</a>
									<c:if test="${item.staffer.enabled=='Y' && item.staffer.id!=-1}"><a href="javascript:doPause('${item.staffer.id}');">停用</a></c:if>
									<c:if test="${item.staffer.id!=-1}"><a href="javascript:doDelete('${item.staffer.id}');">删除</a></c:if>
								</td>
							</tr>
							</c:forEach>							
						</table>
			  </div>
			</div>
		</div>
</body>
</html>